from LeetCoder import *



class Solution:

    def sumDistance(self, nums: List[int], s: str, d: int) -> int:
        mod = 1000000007
        for i in range(len(nums)):
            if s[i] == 'R':
                nums[i] += d
            else:
                nums[i] -= d
        nums.sort()
        ans = 0
        s = nums[0]
        for i in range(1, len(nums)):
            ans += abs(nums[i] * i - s)
            ans %= mod
            s += nums[i]
        return ans % mod


s = Solution()
print(s)
